package com.voice.server.publish.server;

import com.alibaba.fastjson.JSONObject;
import com.voice.core.connection.entity.Stream;
import com.voice.core.connection.entity.StreamData;
import com.voice.server.connection.SdkConnection;
import com.voice.server.publish.PublishHandler;
import org.springframework.stereotype.Component;


@Component("/message/pub/server/port")
public class ServerPortHandler implements PublishHandler<SdkConnection> {

    @Override
    public void handle(Stream stream,StreamData streamData, SdkConnection connection){
        Integer port=JSONObject.parseObject(new String(streamData.readAllData())).getInteger("port");
        connection.setPort(port);
    }
}
